package junit.factory;

public class CarFactory {
    public static Car getIntance(CarType carName) {
        /*if(carName.equals("法拉利")) {
            return new FaLaLi();
        } else if(carName.equals("奔驰")) {
            return new BenChi();
        }
        return null;*/
        //优化，使用枚举
        switch (carName) {
            case FALALI:
                return new FaLaLi();
            case BENCHI:
                return new BenChi();
            default:
                return null;
        }
    }
}
